<?php
class Model_FacultyInformation extends CCMIS_Model {
    //Database faculty_information

    public function __construct(){
        parent::__construct();
        $this->load->database();
    }

    public function getAll()
    {
        $sql = "SELECT * FROM faculty_information";
        $query =  $this->db->query($sql);
        $result = $query->result_array();
        return $result;
        //*/

        /*
        $result = array();
        array_push($result, array(
            'InformationID'=>1,
            'InformationTitle'=>'Profasdf asdf d df d fdfe',
            'Content'=>"I acknowledge:
That I have an obligation to management,therefore, I shall promote the understanding of information processing methods and procedures to management using every resource at my command.

That I have an obligation to my fellow members,therefore, I shall uphold the high ideals of AITP as outlined in the Association Bylaws. Further, I shall cooperate with my fellow members and shall treat them with honesty and respect at all times.

That I have an obligation to society and will participate to the best of my ability in the dissemination of knowledge pertaining to the general development and understanding of information processing. Further, I shall not use knowledge of a confidential nature to further my personal interest, nor shall I violate the privacy and confidentiality of information entrusted to me or to which I may gain access.

That I have an obligation to my College or University,therefore, I shall uphold its ethical and moral principles.

That I have an obligation to my employer whose trust I hold,therefore, I shall endeavor to discharge this obligation to the best of my ability, to guard my employer's interests, and to advise him or her wisely and honestly.

That I have an obligation to my country,therefore, in my personal, business, and social contacts, I shall uphold my nation and shall honor the chosen way of life of my fellow citizens.

I accept these obligations as a personal responsibility and as a member of this Association. I shall actively discharge these obligations and I dedicate myself to that end.",
            'Uploader'=>10010010, //MemberID
            'DateUploaded'=>"06/03/2014 08:15:30",
        ));
        //*/

        return $result;
    }

    public function getById($id)
    {
        $sql = "SELECT * FROM faculty_information WHERE ID LIKE ?";
        $query =  $this->db->query($sql, $id);
        $result = $query->result_array();
        return $result;
    }

    public function add($title, $content, $uploaderId, $date)
    {
        $sql = "INSERT INTO `faculty_information` (
        `Title`,
        `Content`,
        `UploaderID`,
        `DateUploaded`
        )VALUES (?, ?, ?, ?)"   ;
        $this->db->query($sql, array($title, $content, $uploaderId, $date));
    }

    public function edit($id, $title, $content, $uploaderId, $date)
    {
        $sql = "UPDATE `faculty_information`
        SET
        `Title` = ?,
        `Content` = ?,
        `UploaderID` = ?,
        `DateUploaded` = ?

        WHERE InformationID = ?";

        $this->db->query($sql, array($title, $content, $uploaderId, $date, $id));

    }

    public function deleteById($id)
    {
        $sql = "DELETE FROM `faculty_information` WHERE InformationID LIKE ?";
        $this->db->query($sql, $id);
    }

}
